package com.lizheng.yunservice.wx.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lizheng.yunservice.wx.mapper.WxUserMapper;
import com.lizheng.yunservice.wx.domain.WxUser;
import com.lizheng.yunservice.wx.service.IWxUserService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author 47967
 */
@Service
@Slf4j
@AllArgsConstructor
public class WxUserServiceImpl implements IWxUserService {

	private final WxUserMapper wxUserMapper;

	@Override
	public WxUser getWxUserByOpenId(String openId) throws Exception {
		Wrapper<WxUser> queryWrapper = new QueryWrapper<WxUser>().eq("open_id", openId);
		return wxUserMapper.selectOne(queryWrapper);
	}

	@Override
	public void saveWxUser(WxUser wxUser) throws Exception {
        wxUserMapper.insert(wxUser);
	}
}
